#ifndef BASE_CTMTCPSERVER_H_
#define BASE_CTMTCPSERVER_H_
#include "ct_noncopyable.h"
#include "ctType.h"
#include "ctRWLock.h"

#include <string>
#include <map>
#include <vector>

class ctMTCPServer : private ctNoncopyable
{
        public:
                typedef std::map<int,WORD> Sock2Port;
                typedef Sock2Port::value_type Sock2Port_value_type;
                typedef Sock2Port::iterator Sock2Port_iterator;
                typedef Sock2Port::const_iterator Sock2Port_const_iterator;

                ctMTCPServer(const std::string &name);
                ~ctMTCPServer() ;

                bool bind(const std::string &name,const WORD port);
                int accept(Sock2Port &res);

        private:

                static const int T_MSEC = 2100;    
                static const int MAX_WAITQUEUE = 2000;

                std::string name;
                Sock2Port mapper;
                int kdpfd;
                ctRWLock mlock;
                std::vector<struct epoll_event> epfds;
}; 
#endif //BASE_CTMTCPSERVER_H_

